package com.etc.common;

import com.etc.pojo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 如果程序中抛出 myserviceException，统一处理
 */
@ControllerAdvice
@ResponseBody
public class MyControllerAdvice {

    @ExceptionHandler(value = MyServiceException.class)
    public Result myServiceException(MyServiceException e) {
        e.printStackTrace();
        return Result.fail(e.getMessage());
    }

}
